# !/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2022/3/7 11:03 下午
# @Author : 曹庭
# @File : config.py
# @Software: PyCharm
import redis


class Config(object):
    """配置信息"""
    DEBUG = False

    SECRET_KEY = "DUWHDUHWUAHD"

    # 数据库
    SQLALCHEMY_DATABASE_URI = "mysql://root:root1234@49.234.31.119:3306/course_share"  # macbook pro
    # SQLALCHEMY_DATABASE_URI = "mysql://root:root1234@127.0.0.1:3306/course_share"  # macbook pro
    # SQLALCHEMY_DATABASE_URI = "mysql://root:root1234@127.0.0.1:3306/course_share" # macbook air
    SQLALCHEMY_TRACK_MODIFICATIONS = True

    # redis
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    # flask-session配置
    # session存储方式为redis
    SESSION_TYPE = "redis"
    # 是否对发送到浏览器上session的cookie值进行加密
    SESSION_USE_SIGNER = True
    # session保存数据到redis时启用的链接对象
    SESSION_REDIS = redis.Redis(host=REDIS_HOST, port=REDIS_PORT)  # 用于连接redis的配置
    # SESSION数据的有效期，单位秒
    PERMANENT_SESSION_LIFETIME = 86400
    # 保存到redis的session数的名称前缀
    # SESSION_KEY_PREFIX = "session:"


class DevelopmentConfig(Config):
    """开发模式的配置信息"""
    DEBUG = True


class ProductionConfig(Config):
    """生产环境配置信息"""
    pass


config_map = {
    "develop": DevelopmentConfig,
    "product": ProductionConfig
}
